package com.kgc.scd.service.impl;

import com.kgc.scd.util.SnowUtil;
import com.kgc.scd.vo.SensitiveWord;
import com.kgc.scd.mapper.SensitiveWordMapper;
import com.kgc.scd.service.SensitiveWordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created On : 2022/11/12.

 * Description: 敏感词业务接口实现类
 */
@Service
public class SensitiveWordServiceImpl implements SensitiveWordService {

    @Autowired
    private SnowUtil snowUtil;

    @Autowired(required = false)
    private SensitiveWordMapper sensitiveWordMapper;

    @Override
    public List<SensitiveWord> getSensitiveWords() {
        return sensitiveWordMapper.selectList(null);
    }

    @Override
    public boolean addSensitiveWord(Integer tid, String word) {
        SensitiveWord sensitiveWord = new SensitiveWord();
        sensitiveWord.setId(snowUtil.snowId());
        sensitiveWord.setTid(String.valueOf(tid));
        sensitiveWord.setWord(word);
        return sensitiveWordMapper.insert(sensitiveWord) > 0;
    }
}
